package com.drug.controller;

import com.drug.domain.Result;
import com.drug.service.SalesReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Controller
@RequestMapping("/SalesReturn")
public class SalesReturnController {
    @Autowired
    private SalesReturnService salesReturnService;

    /**
     * 退货单查询
     * @param map
     * @param pageNum
     * @return
     */
    @ResponseBody
    @RequestMapping("/findtuohuodan")
    private Result findtuihuodan(@RequestParam Map<String,Object> map,@RequestParam(required=true,defaultValue="1")Integer pageNum){
        return salesReturnService.findtuihuodan(map,pageNum);
    }

    /**
     * 退货单添加
     * @param map
     * @return
     */
    @ResponseBody
    @RequestMapping("/addtuohuodan")
    private Result addtuihuodan(@RequestParam Map<String,Object> map){
        return salesReturnService.addtuihuodan(map);
    }

    /**
     * 查询退货单和商品中间表
     * @param map
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectuohuodan")
    private Result  findAll(@RequestParam Map<String,Object> map,@RequestParam(required=true,defaultValue="1")Integer pageNum){
        return salesReturnService.findAll(map,pageNum);
    }

    /**
     * 添加退货量
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("/addtuihuoliang")
    private Result  addthl(Integer[] diId,Integer[] tuihuoliang,String[] tuihuoyuanyin,Integer zhongjianbiao){
        return salesReturnService.addthl(diId,tuihuoliang,tuihuoyuanyin,zhongjianbiao);
    }

    @RequestMapping("/delectthd")
    private Result  delectthd(Integer id){
        return salesReturnService.delectthd(id);
    }

}
